import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { ConfigService } from './config.service';
import { Singlepage } from '../model/singlepage';

@Injectable()
export class SinglepageService {
  singlepage:Singlepage
  constructor(
    private http:HttpClient,
    private config:ConfigService
  ) { 
    this.singlepage=new Singlepage();
    }

  private addSinglepageUrl=this.config.host+"/manage/addSinglepage";
  addSinglepage(singlepage:Singlepage){
    return this.http.post(this.addSinglepageUrl,singlepage).toPromise();
    }

  private deleteSinglepageUrl=this.config.host+"/manage/deleteSinglepage";
  deleteSinglepage(id:string){
    let p={
      "singlepageid":id,
    }
      return this.http.post(this.deleteSinglepageUrl,p).toPromise();
     }

 private updateSinglepageUrl=this.config.host+"/manage/updateSinglepage";
 updateSinglepage(singlepage:Singlepage){
     let p={
      "singlepageid":singlepage.singlepageid,
      "img":singlepage.img,
      "title":singlepage.title,
      "summary":singlepage.summary,
      "detail":singlepage.detail,
     }
     return this.http.post(this.updateSinglepageUrl,p).toPromise();
     }

     
  private getSinglepageListUrl=this.config.host+"/manage/getSinglepageList";
  getSinglepageList(){
    return this.http.get(this.getSinglepageListUrl).toPromise();
    }

  private getSinglepageUrl=this.config.host+"/manage/getSinglepage";
  getSinglepage(id:string){
    let p={
      "singlepageid":id,
    }
      return this.http.post(this.getSinglepageUrl,p).toPromise();
     }


}
